#include <stdio.h>
#include <stdlib.h>

// 全局变量
int global_var = 5;

int main() {
    // 静态变量
    static int static_var = 6;
    // 局部变量
    int local_var = 7;
    // 申请 100 byte 堆内存
    int *p = (int*)malloc(100);

    // 注意：当前虚拟机为64位机器，这里需要使用 %lx 打印
    printf("the global_var address is %lx\n", &global_var);
    printf("the static_var address is %lx\n", &static_var);
    printf("the local_var address is %lx\n", &local_var);
    // p 指针存储的值即为 malloc 分配的内存首地址
    printf("the address witch the p points to %lx\n", p);

    free(p);
    // 睡眠，保证进程不结束
    sleep(1000);
    return 0;
}